﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DBService;
using System.Web.Services;

public partial class administration_AddPoster : System.Web.UI.Page
{
    static string searchKey = "";
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    [WebMethod]
    public static List<string> GetAllCompaniesByName(string keywordStartsWith)
    {
        //List<string> list = new List<string> { "kakah", "kakha" };
        searchKey = keywordStartsWith;
        ModelAdapter service = new ModelAdapter();
        return service.GetCompaniesNamesByName(keywordStartsWith).Take(10).ToList();
    }

    protected void OnSubmit(object sender, EventArgs e)
    {
        var startDate = DateTime.Parse(dateformId.Value);
        var endDate = DateTime.Parse(datetoid.Value);
        string Logo = "";
        if (UploadLogo.HasFile)
        {
            Logo = Guid.NewGuid().ToString().Substring(0, 10) + "_" + UploadLogo.FileName;
            UploadLogo.SaveAs(Server.MapPath("../upload") + "\\" + Logo);
        }
        var companyName = compName.Value;
        ModelAdapter service = new ModelAdapter();
        service.AddPosters(TitleBox.Value, PhoneBox.Value, AddressBox.Value, CompanyNameInPoster.Value, Logo, description.Value, startDate, endDate, timefrom.Value, timeto.Value);
    }
}